package leetCode.firstWeek;

public class Code_27 {
    public int removeElement(int[] nums, int val) {
        int pStart = 0, pEnd = nums.length - 1, tmp;
        while (pStart <= pEnd) {
            if (nums[pEnd] == val) {
                pEnd--;
                continue;
            }
            if (nums[pStart] == val) {
                tmp = nums[pStart];
                nums[pStart] = nums[pEnd];
                nums[pEnd] = tmp;
            }
            pStart++;
        }
        return pEnd + 1;
    }
}
